﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Procedure = DeltaFlex.Data.ConsProcedures.ClientArticlePreu;

namespace DeltaFlex.Data
{
    public class ClientArticlePreu
    {
        public ClientArticlePreu()
        { }

        #region Inserts
        public static int InsertarClientArticlePreu(int idClient, int idArticle, decimal preu)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = Procedure.SP_INSERTAR_CLIENT_ARTICLE_PREU;
            
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_IDCLIENT, idClient);
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_IDARTICLE, idArticle);
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_PREU, preu);
            
            return Operacions_BD.Insertar(cmd);
        }
        #endregion

        #region Selects
        public static IDataReader CercarClientArticlePreu_ByClientArticle(int idClient, int idArticle)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = Procedure.SP_CERCAR_CLIENT_ARTICLE_PREU;
            
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_IDCLIENT, idClient);
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_IDARTICLE, idArticle);

            return Operacions_BD.Reader(cmd);
        }

        #endregion
    }
}
